package com.zjm.behavioral.memento.theory;

/**
 * 备忘录模式演示1
 */
public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();
        CareTaker careTaker = new CareTaker();

        originator.setState("状态#1：攻击力100");
        // 保存了当前状态
        careTaker.add(originator.saveStateMemento());

        originator.setState("状态#2：攻击力80");
        careTaker.add(originator.saveStateMemento());

        originator.setState("状态#3：攻击力50");
        careTaker.add(originator.saveStateMemento());

        // 希望恢复的状态2
        System.out.println("当前状态是 = " + originator.getState());
        originator.getStateFromMemento(careTaker.get(1));

        System.out.println("恢复的状态2,当前状态是 = " + originator.getState());
    }
}
